package com.hsjk.szwj.module.smedia.controller.admin.job;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.module.smedia.controller.admin.job.vo.AsrJobReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.job.vo.AsrJobRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.job.vo.GetSmartHandleJobRespVO;
import com.hsjk.szwj.module.smedia.service.job.IJob;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/07/21 13:44
 **/
@Tag(name = "管理后台 - 智能媒体任务管理")
@RestController
@RequestMapping("/system/media-job")
@Validated
public class MediaJobController {

    @Resource
    private IJob job;

    @PostMapping("/create-asr-job")
    @Operation(summary = "创建ASR智能字幕任务")
    @PreAuthorize("@ss.hasPermission('system:media-job:create')")
    public CommonResult<AsrJobRespVO> submitASRJob(@Valid @RequestBody AsrJobReqVO reqVO) {
        return success(job.submitASRJob(reqVO));
    }

    @GetMapping("/get-smart-handle-job")
    @Operation(summary = "获取智能任务结果")
    @PreAuthorize("@ss.hasPermission('system:media-job:get')")
    public CommonResult<GetSmartHandleJobRespVO> getSmartHandleJob(String jobId) {
        return success(job.getSmartHandleJob(jobId));
    }
}
